usbuart6 2.2.0
Loading...
Searching...
No Matches
usbuart6.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef USBUART6_H
29#define USBUART6_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
58
63
68
74#define USBUART6_TX_DRV_BUFFER_SIZE 200
75#define USBUART6_RX_DRV_BUFFER_SIZE 200
76 // usbuart6_cmd
78
83
88
93#define USBUART6_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
97 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
99 // usbuart6_map // usbuart6
102
107typedef struct
108{
109 // Output pins
110 digital_out_t en;
111 digital_out_t cts;
112
113 // Input pins
114 digital_in_t rts;
115
116 // Modules
117 uart_t uart;
118
119 // Buffers
122
123} usbuart6_t;
124
129typedef struct
130{
131 // Communication gpio pins
132 pin_name_t rx_pin;
133 pin_name_t tx_pin;
134
135 // Additional gpio pins
136 pin_name_t en;
137 pin_name_t cts;
138 pin_name_t rts;
139
140 // Static variable
141 uint32_t baud_rate;
143 uart_data_bits_t data_bit;
144 uart_parity_t parity_bit;
145 uart_stop_bits_t stop_bit;
146
148
153typedef enum
154{
157
159
165
176
191
204err_t usbuart6_generic_write ( usbuart6_t *ctx, uint8_t *data_in, uint16_t len );
205
218err_t usbuart6_generic_read ( usbuart6_t *ctx, uint8_t *data_out, uint16_t len );
219
229
239
249void usbuart6_set_cts_pin ( usbuart6_t *ctx, uint8_t state );
250
260
261#ifdef __cplusplus
262}
263#endif
264#endif // USBUART6_H
265 // usbuart6
267
268// ------------------------------------------------------------------------ END
#define USBUART6_RX_DRV_BUFFER_SIZE
Definition usbuart6.h:75
#define USBUART6_TX_DRV_BUFFER_SIZE
USB UART 6 driver buffer size.
Definition usbuart6.h:74
err_t usbuart6_generic_read(usbuart6_t *ctx, uint8_t *data_out, uint16_t len)
USB UART 6 data reading function.
err_t usbuart6_init(usbuart6_t *ctx, usbuart6_cfg_t *cfg)
USB UART 6 initialization function.
void usbuart6_set_cts_pin(usbuart6_t *ctx, uint8_t state)
USB UART 6 set CTS pin function.
void usbuart6_cfg_setup(usbuart6_cfg_t *cfg)
USB UART 6 configuration object setup function.
void usbuart6_enable_device(usbuart6_t *ctx)
USB UART 6 enable device function.
void usbuart6_disable_device(usbuart6_t *ctx)
USB UART 6 disable device function.
uint8_t usbuart6_get_rts_pin(usbuart6_t *ctx)
USB UART 6 get RTS pin function.
err_t usbuart6_generic_write(usbuart6_t *ctx, uint8_t *data_in, uint16_t len)
USB UART 6 data writing function.
USB UART 6 Click configuration object.
Definition usbuart6.h:130
pin_name_t rts
Definition usbuart6.h:138
uint32_t baud_rate
Definition usbuart6.h:141
pin_name_t cts
Definition usbuart6.h:137
bool uart_blocking
Definition usbuart6.h:142
uart_data_bits_t data_bit
Definition usbuart6.h:143
pin_name_t tx_pin
Definition usbuart6.h:133
pin_name_t rx_pin
Definition usbuart6.h:132
uart_stop_bits_t stop_bit
Definition usbuart6.h:145
pin_name_t en
Definition usbuart6.h:136
uart_parity_t parity_bit
Definition usbuart6.h:144
USB UART 6 Click context object.
Definition usbuart6.h:108
uart_t uart
Definition usbuart6.h:117
digital_in_t rts
Definition usbuart6.h:114
uint8_t uart_rx_buffer[USBUART6_RX_DRV_BUFFER_SIZE]
Definition usbuart6.h:120
digital_out_t en
Definition usbuart6.h:110
digital_out_t cts
Definition usbuart6.h:111
uint8_t uart_tx_buffer[USBUART6_TX_DRV_BUFFER_SIZE]
Definition usbuart6.h:121
usbuart6_return_value_t
USB UART 6 Click return value data.
Definition usbuart6.h:154
@ USBUART6_OK
Definition usbuart6.h:155
@ USBUART6_ERROR
Definition usbuart6.h:156